/*    */ package com.zimbra.cs.service.account;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AccountConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.account.AccessManager;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.Group;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.ldap.entry.LdapDistributionList;
/*    */ import com.zimbra.cs.account.ldap.entry.LdapDynamicGroup;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class CreateDistributionList
/*    */   extends AccountDocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 39 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 40 */     Provisioning prov = Provisioning.getInstance();
/* 41 */     Account acct = getAuthenticatedAccount(zsc);
/*    */     
/* 43 */     String name = request.getAttribute("name").toLowerCase();
/*    */     
/* 45 */     if (!AccessManager.getInstance().canCreateGroup(acct, name)) {
/* 46 */       throw ServiceException.PERM_DENIED("you do not have sufficient rights to create distribution list");
/*    */     }
/*    */     
/* 49 */     Map<String, Object> attrs = AccountService.getKeyValuePairs(request, "a", "n");
/*    */     
/*    */ 
/* 52 */     boolean dynamic = request.getAttributeBool("dynamic", true);
/*    */     
/*    */ 
/* 55 */     Account creator = getAuthenticatedAccount(zsc);
/* 56 */     Group group = prov.createDelegatedGroup(name, attrs, dynamic, creator);
/*    */     
/* 58 */     ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "CreateDistributionList", "name", name }, attrs));
/*    */     
/*    */ 
/* 61 */     Element response = zsc.createElement(AccountConstants.CREATE_DISTRIBUTION_LIST_RESPONSE);
/* 62 */     Element eDL = response.addElement("dl");
/* 63 */     eDL.addAttribute("name", group.getName());
/* 64 */     if (group.isDynamic()) {
/* 65 */       eDL.addAttribute("ref", ((LdapDynamicGroup)group).getDN());
/*    */     } else {
/* 67 */       eDL.addAttribute("ref", ((LdapDistributionList)group).getDN());
/*    */     }
/* 69 */     eDL.addAttribute("id", group.getId());
/* 70 */     GetDistributionList.encodeAttrs(group, eDL, null);
/*    */     
/* 72 */     return response;
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/account/CreateDistributionList.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */